package com.example.xuanke;

import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

import static org.junit.jupiter.api.Assertions.assertEquals;

@SpringBootTest
public class UserText {

    private static final Logger logger = LoggerFactory.getLogger(UserText.class);

    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    public void testSetValue() {
        // 设置键值对
        redisTemplate.opsForValue().set("zhangsan", "lis");
        logger.info("Redis key 'zhangsan' has been set with value 'lis'.");

        // 获取值
        Object value = redisTemplate.opsForValue().get("zhangsan");
        logger.info("Retrieved value from Redis: {}", value);

        // 断言
        assertEquals("lis", value, "The retrieved value should be 'lis'");
        logger.info("Assertion passed: The value is correct.");
    }
}